<?php
require_once 'application/constant/constant.php';

/**
 * 翻页尺寸取得
 * gcPageSizeService
 * @author    Soochow University
 * @version   1.0
 * @exclude   作  成  日：2011/04/07
 */
class gcPageSizeService{
    /**
     * getPageSizeInfo
     * @param  string  $strPageSizeId
     * @return array 
     */
    public function getPageSizeInfo($strPageSizeId){
        if(!gcConfigRegistry::isRegistered("PageSize")){
            $objPageSizeInfo = new DOMDocument();
            // XML文件读取
            $objPageSizeInfo->load(sysConstant::CONFIG_PAGESIZE_PATH);
            //翻页情报取得
            $objPageSize = $objPageSizeInfo->getElementById($strPageSizeId);

            if($objPageSize){
                $objElement = $objPageSize->getElementsByTagName("*");
                $arrPageSize = array();
                for($ii = 0; $ii < $objElement->length; $ii++){
                    $arrElement = array();
                    $arrElement["KEY_CODE"] = $objElement->item($ii)->getAttribute('size');
                    $arrElement["KEY_NAME"] = $objElement->item($ii)->getAttribute('name');
                    $arrPageSize[] = $arrElement;
                }
            } else {
                $arrPageSize = null;
            }
            unset($objPageSizeInfo);
            gcConfigRegistry::setZend("PageSize", $arrPageSize);
            gcConfigRegistry::set("PageSize", $arrPageSize);
            return $arrPageSize;
        }else {
            $arrPageSize = gcConfigRegistry::get("PageSize");
            gcConfigRegistry::setZend("PageSize", $arrPageSize);
            return $arrPageSize;
        }
    }
}
